package com.wyh.day05.exercises;


import java.util.Scanner;

/**
 * @author 王艺豪
 * @version 1.0
 */
public class Exercise04 {
    public static void main(String[] args) {

//        String str = "192.168.1.1";
//        String[] strs = str.split(".",1);
//        for (Object o :strs) {
//            System.out.println(o);
//        }

        //小测试--实现注册和登录
        Scanner scanner = new Scanner(System.in);
        String username1 = "";
        String password1 = "";
        while (true) {
            System.out.println("=====菜单=====");
            System.out.println("1. 注册");
            System.out.println("2. 登录");
            System.out.println("3. 退出");
            System.out.println("请输入的你选择:");
            int key = scanner.nextInt();
            switch (key) {
                case 1:
                    System.out.println("请输入用户名:");
                    username1 = scanner.next();
                    System.out.println("请输入密码:");
                    password1 = scanner.next();
                    System.out.println("注册成功");
                    break;
                case 2:
                    System.out.println("请输入用户名:");
                    String username2 = scanner.next();
                    System.out.println("请输入密码:");
                    String password2 = scanner.next();
                    if (username2.equals(username1) && password2.equals(password1)) {
                        System.out.println("登录成功");
                    } else if (username2.equals(username1) && !(password2.equals(password1))) {
                        System.out.println("密码错误");
                    } else {
                        System.out.println("登录失败,你还没有注册");
                    }
                    break;
                case 3:
                    System.out.println("退出成功...");
                    return;
            }
        }
    }
}
